import React from 'react';
import ReactDOM from 'react-dom/client';
import { Provider } from 'react-redux';
import { RouterProvider } from 'react-router-dom';
import store from './store/store';
import router from './router';
import { loadTokenFromStorage } from './store/authSlice';
import { NotificationProvider } from '@/context/NotificationContext';

// 在应用启动时加载token
store.dispatch(loadTokenFromStorage());

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
    <Provider store={store}>
      <NotificationProvider>
        <RouterProvider router={router} />
      </NotificationProvider>
    </Provider>
);